﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StockFinder.Entities
{
    public class Symbol
    {
        public int SymbolId { get; set; }
        public string Name { get; set; }
        public DateTime CreatedDateTime { get; set; }

        public List<DailyPrice> Prices { get; set; }
        public List<WeeklyPrice> WeeklyPrices { get; set; }

        public Symbol()
        {
            WeeklyPrices = new List<WeeklyPrice>();
            Prices = new List<DailyPrice>();
        }

        public WeeklyPrice GetExistingWeeklyPrice(int weekOfYear, int year)
        {
            WeeklyPrice matchingWeeklyPrice = null;

            foreach (WeeklyPrice weeklyPrice in WeeklyPrices)
            {
                if (weeklyPrice.WeekOfYear == weekOfYear &&
                    weeklyPrice.Year == year)
                {
                    matchingWeeklyPrice = weeklyPrice;
                }
            }

            return matchingWeeklyPrice;
        }
    }
}
